home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 7: Sunsite
/
Linux Cubed Series 7 - Sunsite Vol 1.iso
/
system
/
admin
/
linuxcon.000
/
linuxcon
/
linuxconf-1.6
/
misc
/
fopen1.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-06-07
|
605b
|
25 lines
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include "misc.h"
#include "../userconf/userconf.h"
#include "misc.m"
/*
Open a configuration file and print an error message if it can't be done.
Check if root access is needed and prompt the user for the root password
if the program is setuid.
*/
FILE *xconf_fopencfg (const char *fname, const char *mode)
{
int wr_mode = strchr(mode,'w')!=NULL || strchr(mode,'a')!=NULL;;
FILE *ret = NULL;
if (!wr_mode || perm_rootaccess(MSG_U(E_UPDATE,"Update %s"),fname)){
ret = xconf_fopen (fname,mode);
}else{
errno = EPERM;
}
return ret;
}